﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Program20
{
    class Program
    {
        static void Main(string[] args)
        {
            #region ref的实例
            //ref能够将一个变量带入方法中进行改变
            decimal salary = 8000.0M;
            Charge(ref salary);
            Console.WriteLine("工资为：{0,8:C2}" ,salary);
            #endregion

            Console.WriteLine();

            #region 交换两个数
            int num1 = 10;
            int num2 = 20;
            Console.WriteLine("num1是：{0},num2是：{1}", num1, num2);

            Swap(ref num1, ref num2);

            Console.WriteLine("交换后：num1是：{0}，num2是：{1}",num1,num2);
            #endregion
            Console.ReadLine();
        }

        public static void Swap( ref int x,ref int y)
        {
            int tmp = x;
            x = y;
            y = tmp;

        }

        public static void Charge(ref decimal s)
        {
            s -= 600;
            Console.WriteLine("这个月扣款：{0,8:C2}" ,600);
        }
    }
}
